package string;

import org.junit.Test;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 生成10万行的字符串到txt中
 * <P> Date: 2022/3/19:21:54
 * <P> Description:
 */

public class StringTest1 {
    static Random random = new Random();
    public static void main(String[] args) throws IOException {
        FileWriter fw = new FileWriter("words.txt");

        for (int i = 0; i < 100000; i++) {
            int length = (int)(Math.random()*(10-1+1)+1);
            fw.write(getString(length)+"\n");
        }

        fw.close();
    }

    public static String getString(int length){
        String str = "";
        for (int i = 0; i < length; i++) {

            int num = (int) (Math.random()*(90-65+1) +
                    (int)(Math.random()*2)*32)+32;
            str+=(char)num;
        }
        return str;
    }
}
